package com.zdy.state;

/**
 * Created by 逸足天涯
 * on 3/9/2020.
 */
//测试礼让线程
//    礼让不一定成功
public class TestYield implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程开始执行！");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"线程停止执行！");
    }

    public static void main(String[] args) {
        TestYield testYield = new TestYield();

        //开启线程
        new Thread(testYield,"A").start();
        new Thread(testYield,"B").start();
    }
}
